<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<meta charset="utf-8">
<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="telephone=no" name="format-detection">
<meta content="email=no" name="format-detection">
<title>信息修改</title>
<link th:href="@{/ksdH5/css/public/mui/mui.css}" rel="stylesheet"/>
<script th:src="@{/ksdH5/js/public/mui/mui.min.js}"></script>
<script th:src="@{/ksdH5/js/public/jquery.min.js}"></script>
<script th:src="@{/ksdH5/js/public/public.js}"></script>
<link  th:href="@{/ksdH5/css/myCard/unbundling.css}" rel="stylesheet"/>
</head>
<body>
<div class="mui-content">
	<div class="headerBox">
		<a href="javascript:history.go(-1);" class="headerBox_left"><img th:src="@{/ksdH5/img/planList/fanhuiBnt.png}"></a>
		<span>信息修改</span>
		<a href="javascript:void(0);" class="headerBox_right">解绑</a>
	</div>
	<div class="changeCashCardBox" th:object="${limit}">
		<span id="limitId" style="display: none;" th:text="*{iD}"></span>
		<div class="changeCashCardBox_inputBox">
			<span>发卡银行</span>
			<em style="font-weight: bold;"th:text="*{bankName}">中信银行</em>
		</div>
		<div class="changeCashCardBox_inputBox">
			<span>信用卡卡号</span>
			<em style="font-weight: bold;" id="cardNo" th:text="*{bankAccount}"></em>
		</div>
		<div class="changeCashCardBox_inputBox">
			<span>账单日</span>
			<input type="tel" id="billDay" maxlength="2" th:value="*{billDay}"  />
		</div>
		<div class="changeCashCardBox_inputBox">
			<span>还款日</span>
			<input type="tel"maxlength="2" id="repaymentDay" th:value="*{repaymentDay}"  />
		</div>
		<div class="changeCashCardBox_inputBox">
			<span>额度</span>
			<input type="tel" id="limitMoney" th:value="*{limitMoney}"/>
		</div>
		<div class="changeCashCardBox_inputBox">
			<span>有效期</span>
			<input type="tel" id="expdate" th:value="*{expdate}" maxlength="4" />
		</div>
		<div class="changeCashCardBox_inputBox">
			<span>CVN2</span>
			<input type="tel" id="cvn" th:value="*{cvn}" maxlength="3" />
		</div>
		<div class="changeCashCardBox_inputBox">
			<span>预留手机号</span>
			<input type="tel"  id="bankPhone" th:value="*{bankPhone}" />
		</div>
	</div>
	<div id="redit_confim_div" class="m_s_l_tishi" style="display: none">
			<label class="loginBox_contBox_tishi_left " id='m_s_l_tishi_bnt'>
				<input type="checkbox" id="credit_confim_box" class="loginBox_contBox_tishi_left_input" />确认信息无误直接提交
			</label>
	</div>
	<a href="javascript:void(0);" onclick="submitEdit()" class="changeCashCardBox_bnt" style="line-height: 0.8rem;text-align: center;">确认</a>
</div>
<!--弹窗-->
<div class="huiseBox"></div>
<div class="confirm">
	<div class="succeed_topBox">
		<div class="succeed_topBox_title">解绑</div>
		<div class="succeed_topBox_cont">解绑后无法使用该卡制定计划，是否解绑该卡。</div>
	</div>
	<div class="confirm_bntBox">
		<a href="javascript:void(0);" class="confirm_bntBox_left">取消</a>
		<a href="javascript:void(0);" onclick="unBind()"  class="confirm_bntBox_right">确定</a>
	</div>
</div>
</body>
<script type="text/javascript" th:inline="javascript">
//获得项目根路径
var ctx = [[@{/}]];
</script>
<script type="text/javascript">
mui.init({
	swipeBack:true
})

$(document).on('click','.headerBox_right',function(){
	$('.huiseBox').show();
	$('.confirm').show();
})
$(function(){
	//复选框点击方法
	$('.loginBox_contBox_tishi_left').on('click',function(){
			$('.loginBox_contBox_tishi_left').toggleClass("active");
	});
})
$(document).on('click','.confirm_bntBox_left',function(){
	$('.huiseBox').hide();
	$('.confirm').hide();	
})
var submitAddNum=1;//定义的提交绑卡次数
//提交修改操作 
 function submitEdit(){
	 var isChecked = $('#credit_confim_box').prop('checked');
		if(submitAddNum==3){
			if(!isChecked){
				submitAddNum=2;
			} 
		}
	var id = $("#limitId").text();
	var cvn = $.trim($("#cvn").val());
	var limitMoney = $.trim($("#limitMoney").val());
	var billDay = $.trim($("#billDay").val());
	var repaymentDay = $.trim($("#repaymentDay").val());
	var expdate = $.trim($("#expdate").val());
	var bankPhone = $.trim($("#").val());
	
	var credit_bank_phone =$.trim($("#bankPhone").val()) ;//银行预留手机号
	var length = credit_bank_phone.length;
	var phone=/^1[3456789]\d{9}$/;
	if(length != 11 || !phone.test(credit_bank_phone)){
		mui.toast("手机号填写错误",{ duration:'long'});
		return;
	}
	var credit_expdate = $.trim($("#expdate").val());//有效期
	var  expdateLen = credit_expdate.length;
	if(expdateLen != 4 ){
		mui.toast("请填写正确有效期",{ duration:'long'});
		return;
	}
	var credit_cvn = $.trim($("#cvn").val());//cvn
	var cvnLen=credit_cvn.length;
	if(cvnLen !=3){
		mui.toast("请填写正确的安全码",{ duration:'long'});
		return;
	}
	var credit_limit_money = $.trim($("#limitMoney").val());//额度
	if(credit_limit_money==""){
		mui.toast("请填写正确的额度",{ duration:'long'});
		return;
	}
	var credit_bill_day = $.trim($("#billDay").val());//账单日
	var billDayLen=credit_bill_day.length;
	if(billDayLen>2 ||billDayLen==0){
		mui.toast("请填写正确的账单日",{ duration:'long'});
		return;
	}
	var credit_repayment_day = $.trim($("#repaymentDay").val());//还款日
	var repaymentDayLen=credit_repayment_day.length;
	if(repaymentDayLen>2 || repaymentDayLen==0){
		mui.toast("请填写正确的还款日",{ duration:'long'});
		return;
	}
	
	$.ajax({
		url : ctx +"h5/card/editCreditCard",
		dataType : "json",
		type : "POST",
		data:{
			"id":id,
			"expdate":credit_expdate,
			"cvn":credit_cvn,
			"limitMoney":credit_limit_money,
			"billDay":credit_bill_day,
			"repaymentDay":credit_repayment_day,
			"bankPhone":credit_bank_phone,
			"num":submitAddNum,
		},
		success : function(re) {
			if(re.status=="out"){
				//跳转登陆页面
				location.href = ctx + 'h5/login';
			}
			submitAddNum = submitAddNum+1;
			if(submitAddNum==3){
				$("#redit_confim_div").show();
			}
			if(re.status=="SUCCESS"){
				mui.toast(re.msg,{ duration:'long'});
				//返回列表
				setTimeout(function (){
					window.history.go(-1);
				}, 1000);
			}else {
				mui.toast(re.msg,{ duration:'long'});
				return;
			}
		}
	});
}
//解绑信用卡
 function unBind(){
	 var cardNo = $("#cardNo").text();
		$.ajax({
			url : ctx +"h5/card/unBind",
			dataType : "json",
			type : "POST",
			data:{
				"cardNo":cardNo
			},
			success : function(re) {
				if(re.status=="out"){
					//跳转登陆页面
					location.href = ctx + 'h5/login';
				}
				submitAddNum = submitAddNum+1;
				if(re.status=="SUCCESS"){
					mui.toast(re.msg,{ duration:'long'});
					//返回列表
					setTimeout(function (){
						window.location.href=ctx+"h5/card/creditCard";
					}, 1000);
				}else {
					mui.toast(re.msg,{ duration:'long'});
					return;
				}
			}
		});
 }

</script>

</html>
